Repository navigation
RV32IM: Add rejection sampling in assembly - #1589
Open
mkannwischer wants to merge 3 commits into
Open
mkannwischer wants to merge 3 commits into
mkannwischer wants to merge 3 commits into
Conversation
mkannwischer
force-pushed
the
rv32im-rej-uniform
branch
from
November 28, 2026 02:49
8c74418 to
b34f01a
Compare
Contributor
Author
|
Marking this as |
Contributor
CBMC Results (ML-DSA-44)
Full Results (447 configurations)
|
Contributor
CBMC Results (ML-DSA-44, REDUCE-RAM)
Full Results (447 configurations)
|
Contributor
CBMC Results (ML-DSA-65)
Full Results (447 configurations)
|
Contributor
CBMC Results (ML-DSA-65, REDUCE-RAM)
Full Results (447 configurations)
|
Contributor
CBMC Results (ML-DSA-87, REDUCE-RAM)
Full Results (447 configurations)
|
Contributor
CBMC Results (ML-DSA-87)
Full Results (447 configurations)
|
mkannwischer
force-pushed
the
rv32im-rej-uniform
branch
from
November 28, 2026 09:12
b34f01a to
63636f9
Compare
Update the pin to 67f472f3 from upstream main. This includes the full RV32IM instruction model from awslabs/s2n-bignum#493. Regenerate the accepted HOLTrace files for the new pin. awslabs/s2n-bignum#524 records the branch outcome in EventJump. Add it to the explicit event traces of the rej_uniform_eta2/eta4 proofs on AArch64 and x86_64 and of the AVX2 Keccak-f1600 x4 proof. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
The rej_uniform unit test ended at the first input the native function declined, and reported success. A backend that declines unaligned input therefore stopped the test at the first odd input address. Skip the declined input instead. Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
Add an RV32IM implementation of rej_uniform. It reads the input in
groups of three words and extracts four 23-bit candidates from each.
The wrapper falls back to C unless the output is a full polynomial and
the input is a 4-byte aligned, non-empty multiple of 12 bytes. Add
uintptr_t to the CBMC stdint headers for the alignment check.
Prove in HOL Light that the routine writes the first (at most 256)
elements of REJ_SAMPLE of its input to the output, returns their
number, and accesses only the input and the output. Beyond the C
contract, the theorem assumes that the output and input are 4-byte
aligned and do not wrap around the address space. There is no
constant-time theorem: the input is public and the control flow
depends on it.
Cycles on Ibex (Pavona, Verilator), compared to the RV32IM backend
without this routine. Rejection sampling of 840 bytes (the first
ExpandA squeeze), averaged over 32 random inputs:
| Before | After | Change
rej_uniform | 5138 | 2216 | -56.87%
Full scheme (sign: expected cost over the average number of attempts):
| Before | After | Change
ML-DSA-44 keygen | 599942 | 549573 | -8.40%
ML-DSA-44 sign | 3272899 | 3046020 | -6.93%
ML-DSA-44 verify | 705724 | 654358 | -7.28%
ML-DSA-65 keygen | 975795 | 876966 | -10.13%
ML-DSA-65 sign | 5787590 | 5288109 | -8.63%
ML-DSA-65 verify | 1118205 | 1016375 | -9.11%
ML-DSA-87 keygen | 1592513 | 1419957 | -10.84%
ML-DSA-87 sign | 7235283 | 6524539 | -9.82%
ML-DSA-87 verify | 1771505 | 1594350 | -10.00%
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
mkannwischer
force-pushed
the
rv32im-rej-uniform
branch
from
November 30, 2026 07:34
63636f9 to
c6f2548
Compare
mkannwischer
marked this pull request as ready for review
November 30, 2026 12:13
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an RV32IM implementation of rej_uniform. It reads the input in
groups of three words and extracts four 23-bit candidates from each.
The wrapper falls back to C unless the output is a full polynomial and
the input is a 4-byte aligned, non-empty multiple of 12 bytes. Add
uintptr_t to the CBMC stdint headers for the alignment check.
Prove in HOL Light that the routine writes the first (at most 256)
elements of REJ_SAMPLE of its input to the output, returns their
number, and accesses only the input and the output. Beyond the C
contract, the theorem assumes that the output and input are 4-byte
aligned and do not wrap around the address space. There is no
constant-time theorem: the input is public and the control flow
depends on it.
Cycles on Ibex (inside of Pavona using Verilator), compared to the RV32IM backend
without this routine. Rejection sampling of 840 bytes (the first
ExpandA squeeze), averaged over 32 random inputs:
Full scheme (sign: expected cost over the average number of attempts):